﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using ITViet.Domains;
using ITViet.Data;

#endregion

namespace ITViet.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="ProductLocaleProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class ProductLocaleProviderBaseCore : EntityProviderBase<ITViet.Domains.ProductLocale, ITViet.Domains.ProductLocaleKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, ITViet.Domains.ProductLocaleKey key)
		{
			return Delete(transactionManager, key.Id);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_id">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _id)
		{
			return Delete(null, _id);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _id);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		FK_tblProductLocale_tblProduct Description: 
		/// </summary>
		/// <param name="_productId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByProductId(System.Int32 _productId)
		{
			int count = -1;
			return GetByProductId(_productId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		FK_tblProductLocale_tblProduct Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_productId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		/// <remarks></remarks>
		public TList<ProductLocale> GetByProductId(TransactionManager transactionManager, System.Int32 _productId)
		{
			int count = -1;
			return GetByProductId(transactionManager, _productId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		FK_tblProductLocale_tblProduct Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_productId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByProductId(TransactionManager transactionManager, System.Int32 _productId, int start, int pageLength)
		{
			int count = -1;
			return GetByProductId(transactionManager, _productId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		fkTblProductLocaleTblProduct Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_productId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByProductId(System.Int32 _productId, int start, int pageLength)
		{
			int count =  -1;
			return GetByProductId(null, _productId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		fkTblProductLocaleTblProduct Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_productId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByProductId(System.Int32 _productId, int start, int pageLength,out int count)
		{
			return GetByProductId(null, _productId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblProduct key.
		///		FK_tblProductLocale_tblProduct Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_productId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public abstract TList<ProductLocale> GetByProductId(TransactionManager transactionManager, System.Int32 _productId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		FK_tblProductLocale_tblLanguage Description: 
		/// </summary>
		/// <param name="_languageId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByLanguageId(System.Int32 _languageId)
		{
			int count = -1;
			return GetByLanguageId(_languageId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		FK_tblProductLocale_tblLanguage Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_languageId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		/// <remarks></remarks>
		public TList<ProductLocale> GetByLanguageId(TransactionManager transactionManager, System.Int32 _languageId)
		{
			int count = -1;
			return GetByLanguageId(transactionManager, _languageId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		FK_tblProductLocale_tblLanguage Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_languageId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByLanguageId(TransactionManager transactionManager, System.Int32 _languageId, int start, int pageLength)
		{
			int count = -1;
			return GetByLanguageId(transactionManager, _languageId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		fkTblProductLocaleTblLanguage Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_languageId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByLanguageId(System.Int32 _languageId, int start, int pageLength)
		{
			int count =  -1;
			return GetByLanguageId(null, _languageId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		fkTblProductLocaleTblLanguage Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_languageId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public TList<ProductLocale> GetByLanguageId(System.Int32 _languageId, int start, int pageLength,out int count)
		{
			return GetByLanguageId(null, _languageId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblProductLocale_tblLanguage key.
		///		FK_tblProductLocale_tblLanguage Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_languageId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of ITViet.Domains.ProductLocale objects.</returns>
		public abstract TList<ProductLocale> GetByLanguageId(TransactionManager transactionManager, System.Int32 _languageId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override ITViet.Domains.ProductLocale Get(TransactionManager transactionManager, ITViet.Domains.ProductLocaleKey key, int start, int pageLength)
		{
			return GetById(transactionManager, key.Id, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tblProductLocale index.
		/// </summary>
		/// <param name="_id"></param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public ITViet.Domains.ProductLocale GetById(System.Int32 _id)
		{
			int count = -1;
			return GetById(null,_id, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblProductLocale index.
		/// </summary>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public ITViet.Domains.ProductLocale GetById(System.Int32 _id, int start, int pageLength)
		{
			int count = -1;
			return GetById(null, _id, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblProductLocale index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public ITViet.Domains.ProductLocale GetById(TransactionManager transactionManager, System.Int32 _id)
		{
			int count = -1;
			return GetById(transactionManager, _id, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblProductLocale index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public ITViet.Domains.ProductLocale GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength)
		{
			int count = -1;
			return GetById(transactionManager, _id, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblProductLocale index.
		/// </summary>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public ITViet.Domains.ProductLocale GetById(System.Int32 _id, int start, int pageLength, out int count)
		{
			return GetById(null, _id, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblProductLocale index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.ProductLocale"/> class.</returns>
		public abstract ITViet.Domains.ProductLocale GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#region _tblProductLocale_GetByCatLang 
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetByCatLang' stored procedure. 
		/// </summary>
		/// <param name="catId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetByCatLang(System.Int32? catId, System.Int32? langId)
		{
			return GetByCatLang(null, 0, int.MaxValue , catId, langId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetByCatLang' stored procedure. 
		/// </summary>
		/// <param name="catId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetByCatLang(int start, int pageLength, System.Int32? catId, System.Int32? langId)
		{
			return GetByCatLang(null, start, pageLength , catId, langId);
		}
				
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetByCatLang' stored procedure. 
		/// </summary>
		/// <param name="catId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetByCatLang(TransactionManager transactionManager, System.Int32? catId, System.Int32? langId)
		{
			return GetByCatLang(transactionManager, 0, int.MaxValue , catId, langId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetByCatLang' stored procedure. 
		/// </summary>
		/// <param name="catId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetByCatLang(TransactionManager transactionManager, int start, int pageLength , System.Int32? catId, System.Int32? langId);
		
		#endregion
		
		#region _tblProductLocale_GetOtherProducts 
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetOtherProducts' stored procedure. 
		/// </summary>
		/// <param name="id"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetOtherProducts(System.Int32? id, System.Int32? categoryId, System.Int32? count, System.Int32? languageId)
		{
			return GetOtherProducts(null, 0, int.MaxValue , id, categoryId, count, languageId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetOtherProducts' stored procedure. 
		/// </summary>
		/// <param name="id"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetOtherProducts(int start, int pageLength, System.Int32? id, System.Int32? categoryId, System.Int32? count, System.Int32? languageId)
		{
			return GetOtherProducts(null, start, pageLength , id, categoryId, count, languageId);
		}
				
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetOtherProducts' stored procedure. 
		/// </summary>
		/// <param name="id"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetOtherProducts(TransactionManager transactionManager, System.Int32? id, System.Int32? categoryId, System.Int32? count, System.Int32? languageId)
		{
			return GetOtherProducts(transactionManager, 0, int.MaxValue , id, categoryId, count, languageId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetOtherProducts' stored procedure. 
		/// </summary>
		/// <param name="id"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetOtherProducts(TransactionManager transactionManager, int start, int pageLength , System.Int32? id, System.Int32? categoryId, System.Int32? count, System.Int32? languageId);
		
		#endregion
		
		#region _tblProductLocale_GetTopHot 
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetTopHot' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetTopHot(System.Int32? langId)
		{
			return GetTopHot(null, 0, int.MaxValue , langId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetTopHot' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetTopHot(int start, int pageLength, System.Int32? langId)
		{
			return GetTopHot(null, start, pageLength , langId);
		}
				
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetTopHot' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetTopHot(TransactionManager transactionManager, System.Int32? langId)
		{
			return GetTopHot(transactionManager, 0, int.MaxValue , langId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetTopHot' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetTopHot(TransactionManager transactionManager, int start, int pageLength , System.Int32? langId);
		
		#endregion
		
		#region _tblProductLocale_GetAllInfoByProductId 
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetAllInfoByProductId' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="productId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllInfoByProductId(System.Int32? langId, System.Int32? productId)
		{
			return GetAllInfoByProductId(null, 0, int.MaxValue , langId, productId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetAllInfoByProductId' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="productId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllInfoByProductId(int start, int pageLength, System.Int32? langId, System.Int32? productId)
		{
			return GetAllInfoByProductId(null, start, pageLength , langId, productId);
		}
				
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetAllInfoByProductId' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="productId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllInfoByProductId(TransactionManager transactionManager, System.Int32? langId, System.Int32? productId)
		{
			return GetAllInfoByProductId(transactionManager, 0, int.MaxValue , langId, productId);
		}
		
		/// <summary>
		///	This method wrap the '_tblProductLocale_GetAllInfoByProductId' stored procedure. 
		/// </summary>
		/// <param name="langId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="productId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetAllInfoByProductId(TransactionManager transactionManager, int start, int pageLength , System.Int32? langId, System.Int32? productId);
		
		#endregion
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;ProductLocale&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;ProductLocale&gt;"/></returns>
		public static TList<ProductLocale> Fill(IDataReader reader, TList<ProductLocale> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				ITViet.Domains.ProductLocale c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("ProductLocale")
					.Append("|").Append((System.Int32)reader[((int)ProductLocaleColumn.Id - 1)]).ToString();
					c = EntityManager.LocateOrCreate<ProductLocale>(
					key.ToString(), // EntityTrackingKey
					"ProductLocale",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new ITViet.Domains.ProductLocale();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.Id = (System.Int32)reader[((int)ProductLocaleColumn.Id - 1)];
					c.ProductId = (System.Int32)reader[((int)ProductLocaleColumn.ProductId - 1)];
					c.LanguageId = (System.Int32)reader[((int)ProductLocaleColumn.LanguageId - 1)];
					c.Name = (System.String)reader[((int)ProductLocaleColumn.Name - 1)];
					c.RefPrice = (reader.IsDBNull(((int)ProductLocaleColumn.RefPrice - 1)))?null:(System.Decimal?)reader[((int)ProductLocaleColumn.RefPrice - 1)];
					c.Description = (reader.IsDBNull(((int)ProductLocaleColumn.Description - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Description - 1)];
					c.Tags = (reader.IsDBNull(((int)ProductLocaleColumn.Tags - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Tags - 1)];
					c.Content = (reader.IsDBNull(((int)ProductLocaleColumn.Content - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Content - 1)];
					c.GuarantyPeriod = (reader.IsDBNull(((int)ProductLocaleColumn.GuarantyPeriod - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.GuarantyPeriod - 1)];
					c.Material = (reader.IsDBNull(((int)ProductLocaleColumn.Material - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Material - 1)];
					c.Original = (reader.IsDBNull(((int)ProductLocaleColumn.Original - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Original - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="ITViet.Domains.ProductLocale"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="ITViet.Domains.ProductLocale"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, ITViet.Domains.ProductLocale entity)
		{
			if (!reader.Read()) return;
			
			entity.Id = (System.Int32)reader[((int)ProductLocaleColumn.Id - 1)];
			entity.ProductId = (System.Int32)reader[((int)ProductLocaleColumn.ProductId - 1)];
			entity.LanguageId = (System.Int32)reader[((int)ProductLocaleColumn.LanguageId - 1)];
			entity.Name = (System.String)reader[((int)ProductLocaleColumn.Name - 1)];
			entity.RefPrice = (reader.IsDBNull(((int)ProductLocaleColumn.RefPrice - 1)))?null:(System.Decimal?)reader[((int)ProductLocaleColumn.RefPrice - 1)];
			entity.Description = (reader.IsDBNull(((int)ProductLocaleColumn.Description - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Description - 1)];
			entity.Tags = (reader.IsDBNull(((int)ProductLocaleColumn.Tags - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Tags - 1)];
			entity.Content = (reader.IsDBNull(((int)ProductLocaleColumn.Content - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Content - 1)];
			entity.GuarantyPeriod = (reader.IsDBNull(((int)ProductLocaleColumn.GuarantyPeriod - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.GuarantyPeriod - 1)];
			entity.Material = (reader.IsDBNull(((int)ProductLocaleColumn.Material - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Material - 1)];
			entity.Original = (reader.IsDBNull(((int)ProductLocaleColumn.Original - 1)))?null:(System.String)reader[((int)ProductLocaleColumn.Original - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="ITViet.Domains.ProductLocale"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="ITViet.Domains.ProductLocale"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, ITViet.Domains.ProductLocale entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.Id = (System.Int32)dataRow["Id"];
			entity.ProductId = (System.Int32)dataRow["ProductId"];
			entity.LanguageId = (System.Int32)dataRow["LanguageId"];
			entity.Name = (System.String)dataRow["Name"];
			entity.RefPrice = Convert.IsDBNull(dataRow["RefPrice"]) ? null : (System.Decimal?)dataRow["RefPrice"];
			entity.Description = Convert.IsDBNull(dataRow["Description"]) ? null : (System.String)dataRow["Description"];
			entity.Tags = Convert.IsDBNull(dataRow["Tags"]) ? null : (System.String)dataRow["Tags"];
			entity.Content = Convert.IsDBNull(dataRow["Content"]) ? null : (System.String)dataRow["Content"];
			entity.GuarantyPeriod = Convert.IsDBNull(dataRow["GuarantyPeriod"]) ? null : (System.String)dataRow["GuarantyPeriod"];
			entity.Material = Convert.IsDBNull(dataRow["Material"]) ? null : (System.String)dataRow["Material"];
			entity.Original = Convert.IsDBNull(dataRow["Original"]) ? null : (System.String)dataRow["Original"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="ITViet.Domains.ProductLocale"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">ITViet.Domains.ProductLocale Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, ITViet.Domains.ProductLocale entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region ProductIdSource	
			if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) 
				&& entity.ProductIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.ProductId;
				Product tmpEntity = EntityManager.LocateEntity<Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.ProductIdSource = tmpEntity;
				else
					entity.ProductIdSource = DataRepository.ProductProvider.GetById(transactionManager, entity.ProductId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.ProductIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion ProductIdSource

			#region LanguageIdSource	
			if (CanDeepLoad(entity, "Language|LanguageIdSource", deepLoadType, innerList) 
				&& entity.LanguageIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.LanguageId;
				Language tmpEntity = EntityManager.LocateEntity<Language>(EntityLocator.ConstructKeyFromPkItems(typeof(Language), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.LanguageIdSource = tmpEntity;
				else
					entity.LanguageIdSource = DataRepository.LanguageProvider.GetById(transactionManager, entity.LanguageId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'LanguageIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.LanguageIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.LanguageProvider.DeepLoad(transactionManager, entity.LanguageIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion LanguageIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetById methods when available
			
			#region ProductFeatureCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<ProductFeature>|ProductFeatureCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'ProductFeatureCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.ProductFeatureCollection = DataRepository.ProductFeatureProvider.GetByProductId(transactionManager, entity.Id);

				if (deep && entity.ProductFeatureCollection.Count > 0)
				{
					deepHandles.Add("ProductFeatureCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<ProductFeature>) DataRepository.ProductFeatureProvider.DeepLoad,
						new object[] { transactionManager, entity.ProductFeatureCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the ITViet.Domains.ProductLocale object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">ITViet.Domains.ProductLocale instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">ITViet.Domains.ProductLocale Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, ITViet.Domains.ProductLocale entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region ProductIdSource
			if (CanDeepSave(entity, "Product|ProductIdSource", deepSaveType, innerList) 
				&& entity.ProductIdSource != null)
			{
				DataRepository.ProductProvider.Save(transactionManager, entity.ProductIdSource);
				entity.ProductId = entity.ProductIdSource.Id;
			}
			#endregion 
			
			#region LanguageIdSource
			if (CanDeepSave(entity, "Language|LanguageIdSource", deepSaveType, innerList) 
				&& entity.LanguageIdSource != null)
			{
				DataRepository.LanguageProvider.Save(transactionManager, entity.LanguageIdSource);
				entity.LanguageId = entity.LanguageIdSource.Id;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
	
			#region List<ProductFeature>
				if (CanDeepSave(entity.ProductFeatureCollection, "List<ProductFeature>|ProductFeatureCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(ProductFeature child in entity.ProductFeatureCollection)
					{
						if(child.ProductIdSource != null)
						{
							child.ProductId = child.ProductIdSource.Id;
						}
						else
						{
							child.ProductId = entity.Id;
						}

					}

					if (entity.ProductFeatureCollection.Count > 0 || entity.ProductFeatureCollection.DeletedItems.Count > 0)
					{
						//DataRepository.ProductFeatureProvider.Save(transactionManager, entity.ProductFeatureCollection);
						
						deepHandles.Add("ProductFeatureCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< ProductFeature >) DataRepository.ProductFeatureProvider.DeepSave,
							new object[] { transactionManager, entity.ProductFeatureCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region ProductLocaleChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>ITViet.Domains.ProductLocale</c>
	///</summary>
	public enum ProductLocaleChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Product</c> at ProductIdSource
		///</summary>
		[ChildEntityType(typeof(Product))]
		Product,
			
		///<summary>
		/// Composite Property for <c>Language</c> at LanguageIdSource
		///</summary>
		[ChildEntityType(typeof(Language))]
		Language,
	
		///<summary>
		/// Collection of <c>ProductLocale</c> as OneToMany for ProductFeatureCollection
		///</summary>
		[ChildEntityType(typeof(TList<ProductFeature>))]
		ProductFeatureCollection,
	}
	
	#endregion ProductLocaleChildEntityTypes
	
	#region ProductLocaleFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;ProductLocaleColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ProductLocale"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ProductLocaleFilterBuilder : SqlFilterBuilder<ProductLocaleColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ProductLocaleFilterBuilder class.
		/// </summary>
		public ProductLocaleFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ProductLocaleFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ProductLocaleFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ProductLocaleFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ProductLocaleFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ProductLocaleFilterBuilder
	
	#region ProductLocaleParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;ProductLocaleColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ProductLocale"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ProductLocaleParameterBuilder : ParameterizedSqlFilterBuilder<ProductLocaleColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ProductLocaleParameterBuilder class.
		/// </summary>
		public ProductLocaleParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ProductLocaleParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ProductLocaleParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ProductLocaleParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ProductLocaleParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ProductLocaleParameterBuilder
	
	#region ProductLocaleSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;ProductLocaleColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ProductLocale"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class ProductLocaleSortBuilder : SqlSortBuilder<ProductLocaleColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ProductLocaleSqlSortBuilder class.
		/// </summary>
		public ProductLocaleSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion ProductLocaleSortBuilder
	
} // end namespace
